package cn.ljn.basic.controller;

import cn.ljn.basic.dto.BinderDto;
import cn.ljn.basic.dto.LoginDto;
import cn.ljn.basic.dto.WxChatDto;
import cn.ljn.basic.service.LoginService;
import cn.ljn.basic.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private LoginService loginService;

    /**
    账号密码登录
     */
    @PostMapping("/account")
    public AjaxResult account(@RequestBody @Valid LoginDto loginDto) {
            return loginService.account(loginDto);
    }

    /**
     微信登录
     */
    @PostMapping("/wechat")
    public AjaxResult wechat(@RequestBody @Valid WxChatDto dto) {
        return loginService.wechat(dto);
    }

    /**
     绑定
     */
    @PostMapping("/wechat/binder")
    public AjaxResult binder(@RequestBody @Valid BinderDto dto) {
        return loginService.binder(dto);
    }

}
